﻿using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using FutureApp.Users;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace FutureApp.Shop
{
    /// <summary>
    /// 货品
    /// </summary>
    [Table("GoodsItems")]
    public class GoodsItem : FullAuditedEntity<Guid, User>, IPassivable, IMayHaveTenant
    {
        /// <summary>
        /// <see cref="SerialNo"/> 属性的最大长度
        /// </summary>
        public const int MaxSerialNoLength = 20;

        /// <summary>
        /// <see cref="Name"/> 属性的最大长度
        /// </summary>
        public const int MaxNameLength = 50;

        /// <summary>
        /// 商品货号
        /// </summary>
        [Required]
        [StringLength(MaxSerialNoLength)]
        public virtual string SerialNo { get; set; }

        /// <summary>
        /// 商品名称
        /// </summary>
        [Required]
        [StringLength(MaxNameLength)]
        public virtual string Name { get; set; }

        /// <summary>
        /// 商品品牌ID
        /// </summary>
        [Required]
        public virtual Guid BrandId { get; set; }

        /// <summary>
        /// 商品品牌
        /// </summary>
        [ForeignKey(nameof(BrandId))]
        public virtual GoodsBrand Brand { get; set; }

        /// <summary>
        /// 商品模型Id
        /// </summary>
        public virtual Guid MouldId { get; set; }

        /// <summary>
        /// 商品模型
        /// </summary>
        [ForeignKey(nameof(MouldId))]
        public virtual GoodsMould Mould { get; set; }

        /// <summary>
        /// 商品分类Id
        /// </summary>
        public virtual Guid CategoryId { get; set; }

        /// <summary>
        /// 商品分类
        /// </summary>
        [ForeignKey(nameof(CategoryId))]
        public virtual GoodsCategory Category { get; set; }

        /// <summary>
        /// 商品SKU
        /// </summary>
        [ForeignKey("ItemId")]
        public virtual ICollection<Goods> GoodsList { get; set; }

        /// <summary>
        /// 激活/禁用
        /// </summary>
        [Required]
        public virtual bool IsActive { get; set; } = true;

        /// <summary>
        /// 租户Id
        /// </summary>
        public virtual int? TenantId { get; set; }
    }
}
